package javaCode.chapter12.string_;

/**
 * @author 徐州城
 * @version 1.0
 */
public class StringExercise05 {
    public static void main(String[] args) {
        Person p1 = new Person();
        p1.name = "xzc";
        Person p2 = new Person();
        p2.name = "xzc";

        System.out.println(p1.name.equals(p2.name)); //T String重写了父类的equals方法
        System.out.println(p1.name == p2.name); //T p1和p2的name 都指向了同一个地址
        System.out.println(p1.name == "xzc"); //T 不是new出来的地址 所以xzc还是在常量池中比较

        String s1 = new String("bcd");
        String s2 = new String("bcd");
        System.out.println(s1 == s2); //F
    }
}

class Person{
    public String name;
}